<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>减少数据读取次数</title>
</head>
<body>
    <div class="skip" id="skip"></div>
    <script>
        var o = document.getElementById('skip')
        function hasEle(ele,cls){
            return ele.className === cls
        }

        // 提前缓存数据，可减少在使用数据时的查找时间
        // 这是牺牲了内存空间换取了执行效率
        function hasEle(ele,cls){
            const className = ele.className
            return className === cls
        }
        console.log(hasEle(o, 'skip'))
    </script>
</body>
</html>